/*
Kakine
ActionScript Framework
Copyright © 2011, PUNY, LLC.

This file is part of KAKINE.

KAKINE is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

KAKINE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with KAKINE.  If not, see <http://www.gnu.org/licenses/>.
*/ 
package com.puny.mvc.views.singleviews
{
	import com.puny.mvc.views.View;
	
	import flash.display.DisplayObject;
	
	/**
	 * $Revision: 647 $
	 * View class for a particle controller
	 */
	public class ParticleView extends View
	{
		protected var _total:int;
		protected var _mcs:Array = new Array();
		private var _name:String;
		private var _sprite:Boolean = false;
		/**
		 * @param src a swf file name, a MovieClipAsset instance, or a Class name
		 * @param exportedName exported name of a MovieClip or Sprite
		 * @param total the total number of particle
		 */
		public function ParticleView(src:Object, exportedName:String, total:int, sprite:Boolean=false)
		{
			_total = total;
			_name = exportedName;
			_sprite = sprite;
			super(src);
		}
		
		/**
		 * @inheritDoc
		 */
		override protected function setup():void {
			for(var i:int = 0;i < _total;i++) {
				if (_sprite) {
					_mcs.push(getSprite(_name,false,false));
				} else {
					_mcs.push(getMovieClip(_name,false,false));
				}
			}
		}
		
		/**
		 * get a MovieClip instance with index.
		 * @return the index-th MovieClip instance
		 */
		public function getMoveClip(index:int):DisplayObject {
			return _mcs[index];
		}
		
	}
}